package server

import (
	"enjoy_wangyashuo/formdata"
	"enjoy_wangyashuo/internal/model/user"
	"enjoy_wangyashuo/pkg"
	"github.com/gin-gonic/gin"
)

func GetAddRListByUserId(c *gin.Context) ([]formdata.AddrInfo, error) {
	userId := pkg.GetAutoUserID(c)

	u := user.UserAddress{
		UserId: userId,
	}
	return u.GetAddrListByUserId()
}
func CreateAddr(data formdata.CreateUserAddr, c *gin.Context) error {
	userId := pkg.GetAutoUserID(c)
	u := user.UserAddress{
		UserId:    userId,
		Name:      data.Name,
		Phone:     data.Phone,
		Province:  data.Province,
		City:      data.City,
		District:  data.District,
		Address:   data.Address,
		IsDefault: data.IsDefault,
	}
	return u.CreateAddress()
}
